
let w = (window.screen.width - 700) / 2;
let h = (window.screen.height - 450) / 2;
let v = new Vue({
    el: 'body>div',
    data: function() {
        return {
            user: {username: '', password: '', checkBox: false},
            setLt1: {display: 'none'},
            setLt2: {display: 'none'},
        }
    },
    methods: {
        checkUsername() {
            if (v.user.username == '' || v.user.username == null) {
                v.setLt1.display = 'block';
            }
        },
        checkPassword() {
            if (v.user.password == '' || v.user.password == null) {
                v.setLt2.display = 'block';
            }
        },
        sets() {
            v.setPosition.top = 500;
            v.setPosition.left = w;

        },
        login() {
            axios.post("/user/loginUser", v.user).then(function (response) {
                switch (response.data) {
                    case 0:
                        v.$message.success("登陆成功!");
                        location.href = '';
                        break;
                    case 1:
                        v.$message.error("账号或密码错误!");
                        break;
                    case 2:
                        if (v.confirm("用户尚未注册,是否现在注册?")) {
                            location.href = 'reg.html';
                        } else {
                            location.reload()

                        }break;

                }

            });
        },
        click(s) {
            v.$message.success('点击了按钮:' + s);
        },
    }
})